/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sudokupso;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Alex
 */
public class SudokuParser {

    /**
     * Parse a input string containing the sudoku game
     * containing the 'X' character on all non-fixed (given)
     * positions, separeted by spaces
     *
     * @param game - a string containting a sokoku game
     * @return the fixed part of the game
     */
    public static int[][] parseSudokuGame(String game) {
        int[][] fixedParts = null;
        String[] lines = game.split("\r\n");
        for (int i=0; i< lines.length;i++) {
            String[] chars = lines[i].split(" ");
            if (fixedParts == null)
                fixedParts = new  int[chars.length][chars.length];

            for (int j = 0; j < chars.length; j++) {
                if (chars[j].trim().equalsIgnoreCase("x"))
                    fixedParts[i][j] = -1;
                else
                    fixedParts[i][j] = Integer.parseInt(chars[j]);
            }
        }
        
        return fixedParts;
    }
}
